package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.ArrayUtils;
import com.sojoys.artifact.tools.SK_String;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 英雄进阶配置
 */
public class HeroProgressCfg extends BaseCfg<HeroProgressCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "hero_progress";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.HeroProgressCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 5;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","进阶消耗","基础属性","成长属性","开启天使技能",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","consume","baseAttr","upAttr","openAngelSkillTree",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","consume","baseAttr","upAttr","openAngelSkillTree",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,951516156,-1722055582,-839870676,-908827784,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","Map","Map","Map","int[]",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Map.class,Map.class,Map.class,int[].class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 进阶消耗
	 */
	private Map consume;
	
	/**
	 * 基础属性
	 */
	private Map baseAttr;
	
	/**
	 * 成长属性
	 */
	private Map upAttr;
	
	/**
	 * 开启天使技能
	 */
	private int[] openAngelSkillTree;
	
	
	
	public static HeroProgressCfg builder() {
		HeroProgressCfg heroProgressCfg = new HeroProgressCfg();
		return heroProgressCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 进阶消耗
	 */
	public Map getConsume() {
		return consume;
	}
	
	/**
	 * 基础属性
	 */
	public Map getBaseAttr() {
		return baseAttr;
	}
	
	/**
	 * 成长属性
	 */
	public Map getUpAttr() {
		return upAttr;
	}
	
	/**
	 * 开启天使技能
	 */
	public int[] getOpenAngelSkillTree() {
		return openAngelSkillTree;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.consume;
        values[2] = this.baseAttr;
        values[3] = this.upAttr;
        values[4] = this.openAngelSkillTree;
        return values;
	}
	
	protected HeroProgressCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.consume = (Map)vals[1];
		this.baseAttr = (Map)vals[2];
		this.upAttr = (Map)vals[3];
		this.openAngelSkillTree = (int[])vals[4];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.consume);
        map.put(keys[2], this.baseAttr);
        map.put(keys[3], this.upAttr);
        map.put(keys[4], this.openAngelSkillTree);
        return map;
    }
    
    protected HeroProgressCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.consume = (Map)map.get(keys[1]);
   		this.baseAttr = (Map)map.get(keys[2]);
   		this.upAttr = (Map)map.get(keys[3]);
   		this.openAngelSkillTree = (int[])map.get(keys[4]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.consume);
        obj.put(keys[2], this.baseAttr);
        obj.put(keys[3], this.upAttr);
        obj.put(keys[4], this.openAngelSkillTree);
        return obj;
    }
    
    protected HeroProgressCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
		this.consume = obj.getObject(keys[1],Map.class);
		this.baseAttr = obj.getObject(keys[2],Map.class);
		this.upAttr = obj.getObject(keys[3],Map.class);
		this.openAngelSkillTree = obj.getObject(keys[4],int[].class);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeObject(this.consume);
	    byteBuf.writeObject(this.baseAttr);
	    byteBuf.writeObject(this.upAttr);
	    byteBuf.writeObject(this.openAngelSkillTree);
    }
	
	protected HeroProgressCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.consume = (Map)byteBuf.readObject();
	    this.baseAttr = (Map)byteBuf.readObject();
	    this.upAttr = (Map)byteBuf.readObject();
	    this.openAngelSkillTree = byteBuf.readIntArray(null);
	    return this;
	}
	
	public HeroProgressCfg deepCopy(){
		HeroProgressCfg heroProgressCfg = null;
		try {
			heroProgressCfg = (HeroProgressCfg) super.clone();
		    heroProgressCfg.consume = ToolCopy.copyObject(this.consume);
		    heroProgressCfg.baseAttr = ToolCopy.copyObject(this.baseAttr);
		    heroProgressCfg.upAttr = ToolCopy.copyObject(this.upAttr);
		    heroProgressCfg.openAngelSkillTree = ToolCopy.copyObject(this.openAngelSkillTree);
			return heroProgressCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return heroProgressCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
